package J_exercise;

public class ex06_oop5 {
	public static void main(String[] args) {
		
		SungJukVO sj=new SungJukVO();
//		sj.name="노윤지"; //맴버변수가 private선언되어서!!
		sj.setName("노윤지");
		System.out.println(sj.getName());
		
		System.out.println("-----------사각형 면적,둘레---------");
		RestangleVO2 re=new RestangleVO2();
		re.setRestangle(10.0f, 10.0f);
		float area=RetangleService.getArea(re.getWidth(), re.getHeight());
		float perimeter=RetangleService.getPerimeter(re.getWidth(), re.getHeight());
		System.out.println("면적="+area+"둘레="+perimeter);
		
		System.out.println();
		System.out.println("---------------선풍기 정보출력---------");
		
		FanVO2 f1=new FanVO2();
		
		f1.setFanVO(10.0f, "yellow", f1.getSlow(), true);
		String s=FanService2.toSting(f1.getOn(), f1.getSpeed(), f1.getRadius(), f1.getColor());
		System.out.println(s);
		
		
		System.out.println();
		System.out.println("---------------은행계좌정보---------");
		AccountVO2 a1=new AccountVO2();
		a1.setBalance(1122, 20_000,4.5F,"2013-06-01");
		float m=AccountService2.getMonthrlyInterestRate(a1.getInterestRate());
		
		System.out.println("계좌번호="+a1.getAid());
		System.out.println("잔액="+a1.getBalance());
		System.out.println("월간이자율="+m+"%");
		System.out.println("통장개설날짜="+a1.getDateCreated());
		System.out.println("2500인출후="+AccountService2.withDraw(a1.getBalance(),2500));
		System.out.println("3000입금후="+AccountService2.deposit(a1.getBalance(),3000));
		
		StockVO2 s1=new StockVO2();
		s1.setStockVO("경영기술", 1_000_000, 750_000);
		System.out.println();
		System.out.println("---------------주가변동률---------");
		float percent=StockService2.getChangePercent(s1.getPreviousClosingPrice(),s1.getCurrentPrice());
		System.out.println(s1.getSname()+" 주가변동률="+percent+"%");
		
	}

}

class SungJukVO
{
	private String name;
	private int  kor;
	private int eng;
	private int mat;
	
	//setter/getter메서드 정의 
	// setXxx메서드 작성법 : 멤버변수 명이 name인경우에 public void setName(){}
	public void setSungjuk(String name,int kor,int eng,int mat)
	{
		this.name=name;	
		this.kor=kor;	
		this.eng=eng;	
		this.mat=mat;	
	}
	public void setName(String name)
	{
		this.name=name;	
	
	}
	
	public String getName()
	{
		return this.name;
	}
	public int getSum()
	{
		return this.kor+this.eng+this.mat;
	}
	
}




class RestangleVO2
{
	private float width;
	private float height;
	
	
	public void setRestangle(float width,float height)
	{this.width=width;	this.height=height;}
	public float getWidth(){return this.width;}
	public float getHeight(){return this.height;}
	
}

class RestangleService2
{
	public static float getArea(float width,float height)
	{
		return width*height;
	}
	public static float getPerimeter(float width,float height)
	{
		return (width+height)*2;
	}
	
}
class FanVO2
{
//상수들은 객체 생성없이 바로 사용가능해야 하므로 따라서,static final이라는 예약어사용
//한편 JDK5이상에서는 이것을 대체하기위해 Enum이라는 새로운 클래스 자료형이 추가됨	
	private static final int slow=1;
	private static final int medium=2;
	private static final int fast=3;
	private boolean on;
	private float radius;
	private String color;
	private int speed;
	
	public FanVO2() //FanVO2 클래스 안의 변수 초기값정의 
	{
		on=false;speed=slow;radius=5.0f;color="blue";
	}
	
	public void setFanVO(float radius,String color,int speed,boolean on)
	{
		this.radius=radius;
		this.on=on;
		this.color=color;
		this.speed=speed;
		
	}
	
	
	public final int getSlow(){return this.slow;} 
	public final int getMedium(){return this.medium;} 
	public final int getFast(){return this.fast;} 
	
	public float getRadius(){ return this.radius; }
	public String getColor(){ return this.color; }
	public int getSpeed(){ return this.speed; }
	public boolean getOn(){ return this.on; }
	
	
}
class FanService2
{
	//모든정보 출력메소드
	static String toSting(boolean on,int speed,float radius,String color)
	{
		if(on)
			return "회전속도"+speed+",색상"+color+",지름"+radius+",작동중";
		else
			return "회전속도"+speed+",색상"+color+",지름"+radius+",정지";
	}
	
	
	
}

class AccountVO2
{
	private int aid;
	private int balance;
	private float interestRate;
	private String dateCreated;
	public AccountVO2()
	{
		aid=0;
		balance=0;
		interestRate=0;
		
	}
	public void setBalance(int aid,int balance,float interestRate,String dateCreated)
	{
		this.balance=balance;
		this.aid=aid;
		this.interestRate=interestRate;
		this.dateCreated=dateCreated;
	}
	
	public int getBalance(){return this.balance;}
	public int getAid(){return this.aid;}
	public float getInterestRate(){return this.interestRate;}
	public String getDateCreated(){return this.dateCreated;}
	
}
class AccountService2
{
	static float getMonthrlyInterestRate(float interestRate)
	{
		return interestRate/12;
	}
	static int withDraw(int balance,int gold)
	{
		balance-=gold;
		return balance; 
	
	}
	static int deposit(int balance,int gold)
	{
		balance+=gold;
				return balance;
	}
	
}
class StockVO2
{
	private String sname;
	private float previousClosingPrice;
	private float currentPrice;
	
	public void setStockVO(String sname,float previousClosingPrice,float currentPrice)
	{
		this.sname=sname;
		this.previousClosingPrice=previousClosingPrice;
		this.currentPrice=currentPrice;
	}
	
	public String getSname (){ return this.sname;}
	public float  getPreviousClosingPrice (){ return this.previousClosingPrice;}
	public float getCurrentPrice (){ return this.currentPrice;}
	
	
	
	
}
class StockService2
{
	static float getChangePercent(float previousClosingPrice,float currentPrice)
	{
		float percent=(currentPrice-previousClosingPrice)/previousClosingPrice*100;
		return percent;
	}
	
}









